package tianqi.controller.user;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import tianqi.service.login.impl.UserServiceImpl;

@Controller
public class Regist {
	@Autowired
	private UserServiceImpl userServiceImpl;

	// 展示 首页
	@RequestMapping("/regist")
	public String showIndex() {
		return "/regist";
	}

	// 注册 并对前台传来的数据，进行二次校验
	@RequestMapping("/checkRegist")
	public String checkRegist(String uname, String pwd, HttpServletRequest req, Model m) {
		String regist = userServiceImpl.regist(uname, pwd, req, m);
		if ("注册成功".equals(regist)) {
			return "youge";
		} else {
			m.addAttribute("msg", regist);
			System.out.println("异常：" + regist);
			return "regist";
		}
	}

	@RequestMapping("/blur")
	@ResponseBody
	public String blur(String uname) {
		return userServiceImpl.blur(uname);
	}
}
